/*
 * @Author: yanzengyong 709402944@qq.com
 * @Date: 2025-08-22 16:25:17
 * @LastEditors: yanzengyong 709402944@qq.com
 * @LastEditTime: 2025-08-22 16:39:59
 * @FilePath: /cyj-framwk-web/src/api/demo/pure-table-fn.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { defHttp } from '/@/utils/http/axios';
import { useMessage } from "/@/hooks/web/useMessage";

const { createConfirm } = useMessage();

enum Api {
  list = '/projectproposalpreparation/projectProposalPreparation/list',
  deleteOne = '/projectproposalpreparation/projectProposalPreparation/delete',
  deleteBatch = '/projectproposalpreparation/projectProposalPreparation/deleteBatch',
  importExcel = '/projectproposalpreparation/projectProposalPreparation/importExcel',
  exportXls = '/projectproposalpreparation/projectProposalPreparation/exportXls',
  queryDataById = '/projectproposalpreparation/projectProposalPreparation/queryById',
}

/**
 * 导出api
 * @param params
 */
export const getExportUrl = Api.exportXls;

/**
 * 导入api
 */
export const getImportUrl = Api.importExcel;

/**
 * 列表接口
 * @param params
 */
export const list = (params) =>
  defHttp.get({url: Api.list, params});

/**
 * 删除单个
 */
export const deleteOne = (params, handleSuccess) => {
  return defHttp.delete({url: Api.deleteOne, params}, {joinParamsToUrl: true}).then(() => {
    handleSuccess();
  });
}

/**
 * 批量删除
 * @param params
 */
export const batchDelete = (params, handleSuccess) => {
  createConfirm({
    iconType: 'warning',
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
        handleSuccess();
      });
    }
  });
}
  
